#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <math.h>

void zzzsmithycardplay(int i, int currentPlayer, int handPos,
		struct gameState* state);

void checkSmithy(int player, struct gameState *post)
{
	struct gameState pre;
	memcpy (&pre, post, sizeof(struct gameState));
	
	int r;
	printf("failure at zzsmithycardplay.\n");
	zzzsmithycardplay(0, player, 0, post);
	
	pre.handCount[player] = pre.handCount[player] + 3;

	assert (r == 0);
	assert (memcmp(&pre, post, sizeof(struct gameState)) == 0);
	printf ("What if it drew different cards so the game state is not equal?\n");
	printf ("Let just check that smithy draws 3 cards, as it should.\n");
	
	int check = pre.handCount[player] - post->handCount[player];
	printf ("pre hand count - post hand count = %d\n", check);
}
int main ()
{
	int i, n, r, p, deckCoutn, discardCount, handCount;
	
	int k[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};
	
	struct gameState G;
	
	printf ("Testing Smithy Card.\n");
	printf ("RANDOM TESTS.\n");
	
	SelectStream(2);
	PutSeed(3);
	
	for(n = 0; n < 20000; n++)
	{
		for (i=0; i < sizeof(struct gameState); i++)
		{
			((char*)&G)[i] = floor(Random() * 256);
		}
		p = floor(Random() * 2);
		G.deckCount[p] = floor(Random() * MAX_DECK);
		G.discardCount[p] = floor(Random() * MAX_DECK);
		G.handCount[p] = floor(Random() * MAX_HAND);
		checkSmithy(p, &G);
	}
}